<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>登录</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
  <!-- Bootstrap 3.3.7 -->
  <{css href="/static/admin/libs/bootstrap/css/bootstrap.min.css"}>
  <!-- Font Awesome -->
  <{css href="/static/admin/libs/font-awesome/css/font-awesome.min.css"}>
  <!-- Ionicons -->
  <{css href="/static/admin/libs/Ionicons/css/ionicons.min.css"}>
  <{css href="/static/admin/libs/layer/theme/default/layer.css"}>
  <{css href="/static/admin/css/AdminLTE.min.css"}>
</head>
<body class="hold-transition login-page">
<div class="login-box">
  <div class="login-logo">
    <a href="/"><b>Live</b>Chat</a>
  </div>
  <!-- /.login-logo -->
  <div class="login-box-body">
    <p class="login-box-msg">登录系统</p>

    <form action="<{:url('index')}>" method="post" onsubmit="return false;">
      <div class="form-group has-feedback">
        <input type="text" class="form-control" placeholder="请输入账号" name="username" id="username">
        <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
      </div>
      <div class="form-group has-feedback">
        <input type="password" class="form-control" placeholder="请输入密码" name="password" id="password">
        <span class="glyphicon glyphicon-lock form-control-feedback"></span>
      </div>
      <div class="row">
        <!-- /.col -->
        <div class="col-xs-4 col-xs-offset-4">
          <button type="submit" class="btn btn-primary btn-block btn-flat" id="btn-login">登录</button>
        </div>
        <!-- /.col -->
      </div>
    </form>
    <!-- /.social-auth-links -->

  </div>
  <!-- /.login-box-body -->
</div>
<!-- /.login-box -->

<{js href="/static/admin/libs/jquery/jquery.min.js"}>
<{js href="/static/admin/libs/bootstrap/js/bootstrap.min.js"}>
<{js href="/static/admin/libs/layer/layer.js"}>
<{js href="/static/admin/js/johnxu.js"}>
<script>
  $(function () {
    $('#btn-login').click(() => {
        let data = {
            username: $('#username').val(),
            password: $('#password').val()
        }

        $.post('', data, (resp) => {
            if (resp.code === 1) {
                johnxu.msg(resp.msg, 'success', function() {
                    window.location.reload()
                })
            } else {
                johnxu.msg(resp.msg, 'warning', function() {
                    $('#username').focus()
                })
            }
        }, 'json')
    })
  })
</script>
</body>
</html>
